import time

from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By


def inMenu(driver):
    driver.find_element(By.XPATH, '//*[text()="固资管理子系统"]').click()
    driver.find_element(By.XPATH, '//*[text()="资产建账"]').click()
    time.sleep(2)

    return driver


def clickState(driver):
    driver.find_element(By.XPATH, '//*[text()="固资管理子系统"]').click()
    driver.find_element(By.XPATH, '//*[text()="资产建账"]').click()
    time.sleep(2)

    return driver


def clickCode(driver):
    menu = driver.find_element_by_xpath('//span[text()="资产编码"]')
    mouse = ActionChains(driver)
    mouse.click(menu).perform()
    return driver


def searchCode(driver):
    driver.find_element_by_xpath(
        '//*[@id="root"]/section/section/section/main/div/div/div/div[2]/div/div/div/div/div[2]/div[1]/div[1]/div[2]/div/div[2]/div[4]/div[1]/div/div/span/input').send_keys(
        'ZC20221122015')
    time.sleep(2)
    return driver


def clearSearch(driver):
    driver.find_element_by_xpath('//span[text()="清空"]').click()
    return driver


def searchAssetsName(driver):
    driver.find_element_by_xpath(
        '//*[@id="root"]/section/section/section/main/div/div/div/div[2]/div/div/div/div/div[2]/div[1]/div[1]/div[2]/div/div[2]/div[5]/div[1]/div/div/span/input').send_keys(
        '建账测试2')
    return driver


def selectState(driver):
    menu = driver.find_element_by_xpath(
        '//*[@id="root"]/section/section/section/main/div/div/div/div[2]/div/div/div/div/div[2]/div[1]/div[1]/div[2]/div/div[2]/div[1]/div[1]/div/div/div')
    mouse = ActionChains(driver)
    mouse.click(menu).perform()
    driver.find_element_by_xpath('//li[text()="待提交"]').click()
    return driver
